package org.scc.service;

import java.util.List;

import org.scc.dao.ResourceDao;
import org.scc.model.Resource;

public class ResourceService {
	private ResourceDao resourceDao;
	
	public ResourceService(){
		resourceDao = new ResourceDao();
	}
	
	public List<Resource> findAll(){
		return resourceDao.findAll();
	}
	
	public Resource load(int id){
		return resourceDao.load(id);
	}
	
	public void add(Resource resource){
		if(null ==resource.getParentRes()){
			resourceDao.addFirstLevel(resource);
		} else {
			resourceDao.addSecondLevel(resource);
		}
	}
	
	public List<Resource> findFirstLevel(){
		return resourceDao.findFirstLevel();
	}
	
	public List<Resource> findSecondLevel(int id){
		return resourceDao.findSecondLevel(id);
	}
	
	public void update(Resource resource){
		resourceDao.update(resource);
	}
	
	public void delete(String ids){
		resourceDao.delete(ids);
	}
}
